Completed
Push — master ( ce82d1...72dc97 )
by greg
01:54
created

post-publish.js ➔ ... ➔ cmsOperations.save.catch   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 3
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
c 0
b 0
f 0
nc 1
dl 3
loc 3
rs 10
nop 1
1
import path from 'path'
2
import {
3
  cmsOperations,
4
  abeExtend,
5
  Manager
0 ignored issues
show
Unused Code introduced by
The variable Manager seems to be never used. Consider removing it.
Loading history...
6
} from '../../cli'
7
8
var route = function(req, res, next){
9
  abeExtend.hooks.instance.trigger('beforeRoute', req, res, next)
10
  if(typeof res._header !== 'undefined' && res._header !== null) return
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
11
12
  var p = cmsOperations.post.publish(
13
    req.body.filePath, 
14
    req.body.tplPath,
15
    req.body.json
16
  );
17
18
  p.then((result) => {
19
    res.set('Content-Type', 'application/json')
20
    res.send(JSON.stringify(result))
21
  },
22
  (result) => {
23
    res.set('Content-Type', 'application/json')
24
    res.send(JSON.stringify(result))
25
  }).catch(function(e) {
26
    console.error('[ERROR] post-publish.js', e)
27
  })
28
}
29
30
export default route